package main

/*

请将这段二进制翻译成中文(unicode编码), 并打印出翻译过程(比如 二进制: 1000 1000 0110 0011, unicode: U+8863, 字符: 衣)
1000 1000 0110 0011
0110 0111 0000 1101
0101 0101 1001 1100
0110 1011 0010 0010
0111 1010 0111 1111
0100 1110 0010 1101
0101 0110 1111 1101
0111 1110 1010 0010

*/

import "fmt"

func transfer() {

	num_list := []int{
		0b1000100001100011,
		0b0110011100001101,
		0b0101010110011100,
		0b0110101100100010,
		0b0111101001111111,
		0b0100111000101101,
		0b0101011011111101,
		0b0111111010100010,
	}

	for _, i := range num_list {
		fmt.Printf("二进制：%16b , unicode编码：%U，字符：%c\n", i, i, i)
	}

}

func HumanBytesLoaded(bytesLength int64) string {
	var (
		resp string
	)

	B := int64(1)
	KB := 1024 * B
	MB := 1024 * KB
	GB := 1024 * MB
	TB := 1024 * GB
	PB := 1024 * TB
	EB := 1024 * PB

	if bytesLength < 1024 {
		resp = fmt.Sprintf("%fB", float64(bytesLength)/float64(B))
	} else if bytesLength < KB {
		resp = fmt.Sprintf("%fKB", float64(bytesLength)/float64(KB))
	} else if bytesLength < MB {
		resp = fmt.Sprintf("%fMB", float64(bytesLength)/float64(MB))
	} else if bytesLength < GB {
		resp = fmt.Sprintf("%fGB", float64(bytesLength)/float64(GB))
	} else if bytesLength < TB {
		resp = fmt.Sprintf("%fTB", float64(bytesLength)/float64(TB))
	} else {
		resp = fmt.Sprintf("%fEB", float64(bytesLength)/float64(EB))
	}
	return resp
}

func lottery() {

}

func main() {
	//work1
	transfer()
	//work2
	res := HumanBytesLoaded(698766)
	fmt.Println(res)
}
